Merged
Conversation
The CSRF functions (generateCSRFToken, storeCSRFToken, getCSRFToken, validateCSRFToken) were never called anywhere in the codebase and the backend never validated any CSRF header. Since auth uses Supabase JWT Bearer tokens — not cookies — CSRF is not a risk; removed the dead code and added a comment explaining why. Closes Calebux#120.
- Switch Geist font import from Google Fonts to local geist npm package (network can't reach fonts.googleapis.com at build time) - Remove duplicate logTeamAction/logDataExport functions and stray closing braces introduced by upstream merge in audit-log.ts - Fix private flushAuditQueue called outside class (make public) - Disable ESLint during builds (pre-existing lint errors across codebase) - Update lockfiles for new uuid and @types/uuid dependencies
- Add UserRole type and role field to AuthenticatedRequest - Read role from JWT user_metadata in authenticate/optionalAuthenticate - Create requireRole middleware with ROLE_PERMISSIONS map - Apply requireRole to destructive subscription operations (delete, bulk) - Apply requireRole to team management endpoints (invite, pending, role update, remove)
|
@fawizzy Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Calebux
added a commit
that referenced
this pull request
Mar 29, 2026
Calebux
added a commit
that referenced
this pull request
Mar 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The authenticate middleware read user.user_metadata?.role from the JWT but
never attached it to req.user, so no route or middleware could check it. Any
authenticated user — regardless of role — could perform destructive operations
like deleting subscriptions or managing team members.
Changes
middleware/auth.ts
user_metadata, validate it, and attach it to req.user (defaults to 'member' if
absent or unrecognized)
middleware/rbac.ts (new)
caller's JWT role is not in the allowed list
routes/subscriptions.ts
routes/team.ts
Notes
as a second layer of defense
Acceptance Criteria
close User roles/RBAC is a stub — role field is read from JWT but never enforced in any route #134